﻿using System;
using System.Net;
using eLongLoginTest.Air_Search_Helper;
using eLongLoginTest.com.elong.gaia.agent.Air_Login;


namespace eLongLoginTest
{
    class Program 
    {
        static void Search() {

            FlightSearchRequestBody rb = new FlightSearchRequestBody();

            rb.from("PEK").
               to("SHE").
               date("2009-08-20").
               time("12:00").
               aircorp("CA").
               cityissued("北京");

            //开一个新的Searcher
            FlightSearcher searcher = new FlightSearcher();
            FlightSearchResponseBody responseBody = searcher.SendRequestAndGetResponse(rb);

            foreach (var item in responseBody.items)
            {
                Console.WriteLine("出发时间:{0}", item.depart);
                item.sites.ForEach(ss=>Console.WriteLine("    机票折扣:{0}",ss.zk));
            }
        }
        

        static void Main(string[] args)
        {
            Air_Login Login = new Air_Login();
            Globals.Globals.cookie = new CookieContainer();
            Login.CookieContainer = Globals.Globals.cookie;
            string login_result = Login.Login("totso", "#######");  


            Console.WriteLine(login_result);

                Search();
                Console.ReadKey();
                Console.WriteLine("===================================");


            Console.ReadKey();
        }
    }
}
